package com.cy.ppj.comm.job;

/**
 * @description: 统计定时任务
 * @author: Ocean
 * @create: 2018-09-03 16:43
 **/

import com.cy.ppj.comm.utils.CommonUtils;
import com.cy.ppj.service.statistics.StatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Calendar;
import java.util.Date;

@Component
public class StatisticsJob {

    @Autowired
    private StatisticsService statisticsService;

    @Scheduled(cron = "0 0 3 * * ?")
    public void statisticsUser() {
        Date time = CommonUtils.addTime(-1, Calendar.DAY_OF_YEAR);
        statisticsService.statisticsUser(time);
    }

    @Scheduled(cron = "0 0 2 * * ?")
    public void statisticsLoanAmount() {
        Date time = CommonUtils.addTime(-1, Calendar.DAY_OF_YEAR);
        Date startTime = CommonUtils.getDayStartTime(time);
        Date endTime = CommonUtils.getDayEndTime(time);
        statisticsService.addStatisticsLoanAmount(startTime, endTime);
    }

}
